package com.example.finalwork2.handler;


import com.example.finalwork2.entity.VehicleSignal;
import org.springframework.stereotype.Component;

@Component
public class SignalClassificationHandler extends AbstractSignalHandler {


    @Override
    public void handle(VehicleSignal data) {

        // 判断是否存在预警
        boolean hasWarning = data.getWarnings() != null && !data.getWarnings().isEmpty();

        // 分类结果打印或标记
        if (hasWarning) {
            System.out.println("该信号归为：存在预警");
            data.setCategory(true);
        } else {
            System.out.println("该信号归为：无预警");
            data.setCategory(false);
        }

        // 继续责任链
        if (next != null) {
            next.handle(data);
        }

    }
}

